Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@endo/patterns
Advanced tools
@endo/patterns
The main export from the package is an M
namespace object, for making a variety of Matchers (hence "M"). For example:
import '@endo/init/debug.js';
import { M, mustMatch } from '@endo/patterns';
const specimen = harden({ foo: 3, bar: 4 });
const pattern = M.splitRecord(
{ foo: M.number() }, // required properties
{ bar: M.string(), baz: M.number() }, // optional
);
mustMatch(specimen, pattern); // throws: 'bar?: number 4 - Must be a string'
See {@link PatternMatchers} for more on M.splitRecord()
, M.number()
, and other methods.
M
also has {@link GuardMakers} methods to make {@link InterfaceGuard}s that use Patterns to characterize dynamic behavior such as method argument/response signatures and promise awaiting. The {@link @endo/exo!} package uses InterfaceGuard
s as the first level of defense for Exo objects against malformed input.
For best rendering, use the Endo reference docs site.
Builds on {@link @endo/pass-style!} as described in kindOf
and passStyleOf
levels of abstraction to define higher level data types as individual refinements of Passable CopyTagged records (PassStyle "tagged"):
In support of the above, there is also {@link compareKeys} and {@link keyEQ} exposing pass-invariant Key comparison, and two concepts with corresponding TypeScript types:
r
may be a child of multiple parents, e.g. { foo: r, bar: [r] }
). A Key is stable and stably comparable with other Keys via {@link keyEQ}. Key is the most general data type covering valid contents for CopySets and CopyBags and keys for CopyMaps (the last of which explains the "Key" name).keyEQ
considers identity only for Remotables, where it is shared across all local Presences of the same Remotable), or a Key-like structure in which one or more leaves is a Matcher rather than a primitive or Remotable.FAQs
Pattern matching for Passable objects, expressed as Passable data
The npm package @endo/patterns receives a total of 1,486 weekly downloads. As such, @endo/patterns popularity was classified as popular.
We found that @endo/patterns demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.